/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.expert.dao;


import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;

import com.chlitina.store.common.persistence.BaseDao;
import com.chlitina.store.common.persistence.BaseDaoImpl;
import com.chlitina.store.modules.expert.entity.ExpertExperienceBasic;

/**
 * 条件方案关联DAO接口
 * @author liujiang
 * @version 2013-06-09
 */
public interface ExpertExperienceBasicDao extends ExpertExperienceBasicDaoCustom, CrudRepository<ExpertExperienceBasic, Long> {
	
	@Query("from ExpertExperienceBasic where MIN_VALUE=?1 and MAX_VALUE=?2")
	public ExpertExperienceBasic findByPK(Long min, Long max);
	
	@Query("from ExpertExperienceBasic where MIN_VALUE<=?1 and MAX_VALUE>=?1")
	public List<ExpertExperienceBasic> findByMiddle(int middleId);
	
	@Query("select count(*) from ExpertExperienceBasic where (MAX_VALUE>?1 and MAX_VALUE<=?2) or (MIN_VALUE>=?1 and MIN_VALUE<?2) or (MIN_VALUE<?1 and MAX_VALUE>?2)")
	public long check(int min, int max);
	
	@Query("select count(*) from ExpertExperienceBasic where ((MAX_VALUE>?1 and MAX_VALUE<=?2) or (MIN_VALUE>=?1 and MIN_VALUE<?2) or (MIN_VALUE<?1 and MAX_VALUE>?2)) and (MIN_VALUE!=?3 and MAX_VALUE!=?4)")
	public long check(int min, int max, Long oldMin, Long oldMax);
	
	@Query("from ExpertExperienceBasic where SOLUTION_ID=?1")
	public List<ExpertExperienceBasic> getBySolution(long solution_id);
}

/**
 * DAO自定义接口
 * @author liujiang
 */
interface ExpertExperienceBasicDaoCustom extends BaseDao<ExpertExperienceBasic> {

}

/**
 * DAO自定义接口实现
 * @author liujiang
 */
@Component
class ExpertExperienceBasicDaoImpl extends BaseDaoImpl<ExpertExperienceBasic> implements ExpertExperienceBasicDaoCustom {

}
